package edu.towson.cosc603.coffeemaker;

import static org.junit.Assert.*;
import junit.framework.TestCase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

public class RecipeTest extends TestCase {
	private CoffeeMaker cm;
	
	private Recipe r;
	private Recipe r1;
	private Recipe r2;
	private Recipe r3;
	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
	}

	@AfterClass
	public static void tearDownAfterClass() throws Exception {
	}

	@Before
	public void setUp() throws Exception {
		cm = new CoffeeMaker();
		r = new Recipe();
		r1 = new Recipe();
		r1.setName("Coffee");
		r1.setPrice(50);
		r1.setAmtCoffee(6);
		r1.setAmtMilk(1);
		r1.setAmtSugar(1);
		r1.setAmtChocolate(0);
		
		r2 = new Recipe();
		r2.setName("Coffee");
		r2.setPrice(75);
		r2.setAmtCoffee(6);
		r2.setAmtMilk(6);
		r2.setAmtSugar(0);
		r2.setAmtChocolate(0);
		
		r3 = new Recipe();
		r3.setName("Hot Chocolate");
		r3.setPrice(100);
		r3.setAmtCoffee(0);
		r3.setAmtMilk(2);
		r3.setAmtSugar(0);
		r3.setAmtChocolate(2);
	}
	

	@After
	public void tearDown() throws Exception {
	}

	@Test
	public void testSetAmtChocolate1() {
		r.setAmtChocolate(1);
		assertEquals(1,r.getAmtChocolate());
	}
	@Test
	public void testSetAmtChocolate2() {
		r.setAmtChocolate(-1);
		assertEquals(0,r.getAmtChocolate());
	}
	@Test
	public void testSetAmtCoffee1() {
		r.setAmtCoffee(1);
		assertEquals(1,r.getAmtCoffee());	
	}
	@Test
	public void testSetAmtCoffee2() {
		r.setAmtCoffee(-1);
		assertEquals(0,r.getAmtCoffee());	
	}
	@Test
	public void testSetAmtMilk1() {
		r.setAmtMilk(1);
		assertEquals(1,r.getAmtMilk());
	}
	@Test
	public void testSetAmtMilk2() {
		r.setAmtMilk(-1);
		assertEquals(0,r.getAmtMilk());
	}
	@Test
	public void testSetAmtSugar1() {
		r.setAmtSugar(1);
		assertEquals(1,r.getAmtSugar());
	}
	@Test
	public void testSetAmtSugar2() {
		r.setAmtSugar(-1);
		assertEquals(0,r.getAmtSugar());
	}
	@Test
	public void testSetName() {
		r.setName("Chai");
		assertEquals("Chai",r.getName());
	}

	@Test
	public void testSetPrice1() {
		r.setPrice(2);
		assertEquals(2,r.getPrice());
	}
	@Test
	public void testSetPrice2() {
		r.setPrice(-2);
		assertEquals(0,r.getPrice());
	}
	@Test
	public void testToString() {
			r.setName("Chai");
			assertEquals("Chai", r.toString());
	}
	
	@Test
	public void testEquals() {
		r.setName("Chai");
		Recipe fail = new Recipe();
		fail.setName("fail");
		assertFalse(r.equals(fail));
		
		Recipe pass = new Recipe();
		pass.setName("Chai");
		assertTrue(r.equals(pass));
		
		assertTrue(r.equals(r));
		//assertFalse(r.getName(null));
		assertFalse(r.equals("wrong class"));
	}
}
